/**
 * @Description: 删除测试文件夹
 * @author Beon
 * @date 2021/1/14
*/
import * as fs from 'fs-extra';

export {
    deleteFolder
};

/**
 * 根据路径删除文件夹
 * @param {String} path 路径
 */
function deleteFolder(path: string): void {
    let files = [];
    if (fs.existsSync(path)) {
        files = fs.readdirSync(path);
        files.forEach(function(file){
            let curPath = path + '/' + file;
            if (fs.statSync(curPath).isDirectory()) {
                deleteFolder(curPath);
            } else {
                fs.unlinkSync(curPath);
            }
        });
        fs.rmdirSync(path);
    }
}
